package com.deyuanyun.pic.pipe.controller.vo;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.pipe.domain.bo.ValveRoomBO;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.github.pagehelper.Page;

import java.util.ArrayList;
import java.util.List;

/**
 * 场站阀室 整合了PIC_PIPE_MAP_VALVEROOM 表 和 PIC_PIPE_VALVEROOM 表
 */
public class ValveRoomVO extends BaseVO<ValveRoomBO>{

    // 场站阀室名称
    private String name;
    // 场站阀室编号(自定义编号)
    private String customNumber;
    // 场站阀室类型
    private String type;
    // 位置描述
    private String locationDescription;
    // 是否具有收发球筒：0，无；1，有
    private String isPiggingDeviceind;
    // 是否具有阴保电源：0，无；1，有
    private String isPowerind;
    // 是否具有放空装置：0，无；1，有
    private String isEmptyingDevice;
    // gis地址
    private String gisId;
    
    private String state;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCustomNumber() {
        return customNumber;
    }

    public void setCustomNumber(String customNumber) {
        this.customNumber = customNumber;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getLocationDescription() {
        return locationDescription;
    }

    public void setLocationDescription(String locationDescription) {
        this.locationDescription = locationDescription;
    }

    public String getIsPiggingDeviceind() {
        return isPiggingDeviceind;
    }

    public void setIsPiggingDeviceind(String isPiggingDeviceind) {
        this.isPiggingDeviceind = isPiggingDeviceind;
    }

    public String getIsPowerind() {
        return isPowerind;
    }

    public void setIsPowerind(String isPowerind) {
        this.isPowerind = isPowerind;
    }

    public String getIsEmptyingDevice() {
        return isEmptyingDevice;
    }

    public void setIsEmptyingDevice(String isEmptyingDevice) {
        this.isEmptyingDevice = isEmptyingDevice;
    }

    public String getGisId() {
        return gisId;
    }

    public void setGisId(String gisId) {
        this.gisId = gisId;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public void fromDomain(ValveRoomBO domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }
        // 场站阀室名称
       this.name = domain.getName();
        // 场站阀室编号
        this.customNumber = domain.getCustomNumber();
        // 场站阀室类型
        this.type = CodeUtil.getName(domain.getType());
        // 位置描述
        this.locationDescription = domain.getLocationDescription();
        // 是否具有收发球筒：0，无；1，有
        this.isPiggingDeviceind = convert(domain.getIsPiggingDeviceind());
        // 是否具有阴保电源：0，无；1，有
        this.isPowerind = convert(domain.getIsPowerind());
        // 是否具有放空装置：0，无；1，有
        this.isEmptyingDevice = convert(domain.getIsEmptyingDevice());
        // gis地址
        this.gisId = domain.getGisId();
        String[] stateArr = new String[]{"启用","停用"};
        this.state = stateArr[domain.getState()];
        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordtime(), domain.getRemark());
    }

    public Page<ValveRoomVO> fromDomainList(Page<ValveRoomBO> domainList) {
        Page<ValveRoomVO> list = new Page<ValveRoomVO>();
        for (ValveRoomBO valveRoomBO : domainList) {
            ValveRoomVO valveRoomVO = new ValveRoomVO();
            valveRoomVO.fromDomain(valveRoomBO);
            list.add(valveRoomVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}
